﻿$DebugPreference = "continue"
$2003Servers = @("chw-msg-301","chw-msg-302","chw-msg-303","chw-msg-401","chw-msg-402","chw-msg-403")
Write-Debug "$2003Servers"
$LogPaths = Get-StorageGroup -IncludePreExchange2007 | ? {$2003Servers -contains $_.Server} | Sort Server | Select Server,Name,LogFolderPath
$LogSpace = @()

ForEach ($lpath in $LogPaths) {
	Write-Debug "Server $($lpath.server)"
	$lp =  $lpath.LogFolderPath.PathName
	Write-Debug "lp $lp"
	$LogDrive = $lp.Remove($lp.IndexOf('\')+1,$lp.length-($lp.IndexOf('\')+1))
	Write-Debug "LogDrive: $Logdrive"
	$LogDriveInfo = Get-WmiObject win32_volume -ComputerName $lpath.server | Where-Object {$_.Name -eq $LogDrive} | Select-Object Name,Capacity,Freespace
	Write-Debug "Logdriveinfo $LogDriveInfo"
	ForEach ($ldi in $LogDriveInfo) {
		$LogInfo = New-Object PSObject
		$LogCount = (Get-Childitem ("\\"+$lpath.server+"\"+$lp.replace(":","$"))).count
		$LogInfo | Add-Member -MemberType NoteProperty -Name Server -Value $lpath.server
		$LogInfo | Add-Member -MemberType NoteProperty -Name Path -Value $lp
		$LogInfo | Add-Member -MemberType NoteProperty -Name LogCount -Value $LogCount
		$LogInfo | Add-Member -MemberType NoteProperty -Name Capacity -Value ("{0:N2}" -f ($ldi.Capacity/1gb))
		$LogInfo | Add-Member -MemberType NoteProperty -Name Freespace -Value ("{0:N2}" -f ($ldi.Freespace/1gb))
		$LogInfo | Add-Member -MemberType NoteProperty -Name PercentFree -Value ("{0:P1}" -f ($ldi.Freespace/$ldi.Capacity))
		$LogSpace += $LogInfo
	}
}

$LogSpace